package com.homedo.microservice.open.service.gateway.manager.web.remote.api.impl;

import com.homedo.common.bean.data.RequestData;
import com.homedo.common.bean.data.ResponseData;
import com.homedo.microservice.open.service.gateway.manager.web.api.IAlertUserRouteServcieServiceRemote;
import com.homedo.microservice.open.service.gateway.manager.web.api.bean.model.req.AlertUserRouteServcieAddAReq;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.service.AlertUserRouteServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AlertUserRouteServcieServiceRemoteImpl implements IAlertUserRouteServcieServiceRemote {
    @Autowired
    private AlertUserRouteServiceService alertUserRouteServiceService;

    @Override
    public ResponseData add(@RequestBody RequestData<AlertUserRouteServcieAddAReq> requestData) {
        ResponseData responseData = new ResponseData();
        AlertUserRouteServcieAddAReq alertUserRouteServcieAddAReq = requestData.getRequest();

        alertUserRouteServiceService.saveAlertUserRouteService(alertUserRouteServcieAddAReq.getServiceId(), alertUserRouteServcieAddAReq.getUsername(), null);

        return responseData;
    }

    @Override
    public ResponseData delete(@PathVariable("alertUserId") Integer alertUserId, @PathVariable("serviceId") String serviceId) {
        ResponseData responseData = new ResponseData();

        alertUserRouteServiceService.deleteAlertUserIdAndServiceId(alertUserId, serviceId, null);

        return responseData;
    }
}
